--Api 表
/*
select * from SYS_Apis
select * from SYS_ApiM --M  Memo Main Manage
ReturnType
返回类型（类似返回值）
1 execSql
2 openSql
3 execProc(不带返回结果)
4 openProc(带返回结果集)
5 getList (使用getList sql 模板)
6 执行updata,delete 等，返回 操作的行数
*/

declare
  @ApiName varchar(50)='sjdg.list',
  @ReturnType int =5
--
--
delete from SYS_Apis where apiName=@ApiName
delete from SYS_ApiM where apiName=@ApiName
insert into SYS_ApiM([apiName],[name],[memo])
select @ApiName,'底稿列表','底稿列表 在复核平台中使用，Api接口中使用'
insert into SYS_Apis(ApiName,paramsLen,params,ReturnType,sqlText)
select @ApiName,0,
'',
@ReturnType,
'select a.dgid,dgnd,dgmc,jdid,dgsyh,dglx,dgzt,editUser,editDate,reviewUser,reviewDate,b.fjCnt,c.sheetCnt,c.wcCnt from [#(dbname)]..sjdg a
left join (select dgid,count(dgid) fjCnt from [#(dbname)]..dglinkinfo where isnull(isdel,0)=0 and LinkType>0 group by dgid) b on a.dgnd+a.dgmc=b.dgid
left join (select dgid,count(sheetIndex) sheetCnt,sum(case when bzwc is null then 0 else 1 end) wcCnt
from [#(dbname)]..sjdgSheet where isnull(isdel,0)=0 and isnull(sheetVisible,1)=1
group by dgid) c on a.dgnd+a.dgmc=c.dgid
where
#if(sjjd==''recycleBin'')
 isnull(dgzt,0)=999
#else
 isnull(dgzt,0)<999
 #if(sjjd) and jdid=#para(sjjd) #end
#end
#if(dgnd) and dgnd=#para(dgnd) #end'
